Skip to content

Conversation

@milancurcic
Copy link
Member

@milancurcic milancurcic commented Feb 6, 2025

Adds input2d layer.

This also changes how input layers of various ranks are constructed.

Currently Fortran generic name can't distinguish between input([10, 10]) and input([10, 10, 10]) (1-d array as input), but it can distinguish between input(10, 10) and input(10, 10, 10) (multiple scalars as input).

Before:

input(32)  ! input1d layer
input([3, 32, 32]) ! input3d layer

This PR:

input(32) ! input1d layer
input(32, 32) ! input2d layer
input(3, 32, 32) ! input3d layer

@OneAdder please review.

This PR is in support of removing the crutch in #197.

TODO:

  • network % {forward,predict,predict_batch}_2d
  • input2d tests
  • input2d example
  • Update CMake
  • Update README.md

@milancurcic milancurcic added the enhancement New feature or request label Feb 6, 2025
@milancurcic milancurcic mentioned this pull request Feb 6, 2025
@OneAdder
Copy link
Collaborator

OneAdder commented Feb 8, 2025

Thank you for your effort, Milan!

Great job figuring out such a handsome solution for generics! Looks really nice.

However, there are several pieces missing for the plumbing part:

nf_network.f90::forward_2d
nf_network.f90::predict_2d
nf_network.f90::predict_batch_2d

nf_layer.f90::backward_2d

Should I add them together with an example in my PR?

@OneAdder OneAdder mentioned this pull request Feb 9, 2025
@milancurcic
Copy link
Member Author

@OneAdder indeed, you're right. If a network begins with a 2-d input layer, then the specific forward, predict, and backward methods need to be added as well. If you don't mind, yes, please go ahead and add them. You should be able to push directly to this PR (rather than a separate PR) by cloning my fork at milancurcic/neural-fortran and checking out the input2d branch.

@OneAdder
Copy link
Collaborator

@milancurcic I made the updates for input2d_layer, added tests and updated CMakeLists and readme

@milancurcic
Copy link
Member Author

Awesome, thanks! I'll take another read through and test locally tonight.

@OneAdder OneAdder mentioned this pull request Feb 15, 2025
@milancurcic milancurcic merged commit a28a9be into modern-fortran:main Feb 16, 2025
4 checks passed
@milancurcic milancurcic deleted the input2d branch February 16, 2025 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants